package learning.spring.helloworld;

import learning.spring.speaker.Speaker;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan("learning.spring.helloworld")// 2、扫描指定包下的类
public class Application {
    public static void main(String[] args) {
        /*
         * 1、创建AnnotationConfigApplicationContext对象，并传入当前类Application.class
         */
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
        Speaker speaker = context.getBean("speaker", Speaker.class);
        System.out.println(speaker.speak());
    }
}
